package net.liteheaven.xblib.common.log;

import android.content.Context;
import android.os.Environment;

import java.io.File;

/**
 * Created by LiangYu on 16/8/29
 */
public class Log4jConfig {

    private static final String FILE_NAME = "log.txt";
    private static final String ZIP_PREFIX = ".zip";
    private static final String LOG_FOLDER = "xlog";

    public static String getLogFileName(){
        return FILE_NAME;
    }

    public static File getLogFolderPath(Context ctx){
        File fDir = Environment.getExternalStoragePublicDirectory(ctx.getPackageName());

        String logPath = fDir.getPath() + File.separator + LOG_FOLDER;
        File logPathFile = new File(logPath);

        if (!logPathFile.exists()){
            logPathFile.mkdirs();
        }

        return logPathFile;
    }

    public static File getLogFilePath(Context ctx){
        File folder = getLogFolderPath(ctx);
        String path = folder.getPath() + File.separator + getLogFileName();
        File file = new File(path);
        return file;
    }

    public static File getZippedFilePath(Context ctx){
        File folder = getLogFolderPath(ctx);
        String path = folder.getPath() + ZIP_PREFIX;
        File file = new File(path);
        return file;
    }
}
